const tool = {
    // 提示组件
    toast: function (status, text) {
        let div = document.createElement("div")
        div.className = "toast ta"
        div.innerHTML = `
        <p class="toastIcon">${status == 1 ? "√" : "!"}</p>
        <p class="toastText">${text}</p>
        `
        document.body.appendChild(div)
        // 每隔两秒把自己删掉
        setTimeout(function () {
            div.remove()
        }, 2000)
    },
    // footer 组件
    footer: function (page) {
        let footer = document.createElement("footer")
        footer.innerHTML = `
        <div class="footerList dpflex">
        <a href='./index.html' class='${page === "index"? "active":""}'>
        <div class="single dpflex">
            <i class="iconfont icon-shouye"></i>
            <p>首页</p>
        </div>
        </a>
        <a href='./sport.html' class='${page === "sport"? "active":""}'>
        <div class="single dpflex">
            <i class="iconfont icon-xintiaojiankangyundongyiliaobaohuxinshuai"></i>
            <p>运动</p>
        </div>
        </a>
        <a href='./personalPage.html' class='${page === "personalPage"? "active":""}'>
        <div class="single dpflex">
            <i class="iconfont icon-wode"></i>
            <p>我的</p>
        </div>
        </a>
        </div>
        `
        document.body.appendChild(footer)
    },
    // 字符串转对象
    searchToObj: function(str){
        let obj = {}
        str = decodeURI(str.substr(1))
        let newArr = str.split("&")
        newArr.forEach(function(item){
            let arr = item.split("=")
            obj[arr[0]] = arr[1]
        })
        return obj
    }
}
window.tool = tool